/*
 * Handle.h
 *
 *  Created on: Nov 6, 2012
 *      Author: root
 */

#ifndef _HANDLE_H_
#define _HANDLE_H_

#include <functional>

#include "Packet.h"
#include "Player.h"

typedef std::function<void (const Packet & packet)> PacketHandle;

typedef std::function<void (const PlayerPtr & player,const Packet & packet)> PlayerPacketHandle;

struct Handler
{
	PacketHandle _filter;

	Handler()
	{
	}

	virtual ~Handler()
	{

	}

	void filt(const Packet & packet)const
	{
		_filter(packet);
	}
};

struct PlayerHandler:public Handler
{
	PlayerPacketHandle _handler;

	PlayerHandler()
	{

	}

	void call(const PlayerPtr & player,const Packet & packet)const
	{
		_handler(player,packet);
	}
};


#endif /* _HANDLE_H_ */
